class HTTP {
    constructor() {
        this.METHOD_GET = 'GET';
        this.METHOD_POST = 'POST';
        this.METHOD_PUT = 'PUT';
        this.METHOD_DELETE = 'DELETE';
    }

    sendRequest(method, url, body = false, headers = false) {
        if (!method || !url) return false;

        const data = {
            method
        };

        if (body) data.body = body;
        if (headers) data.headers = headers;

        return fetch(url, data);
    }

    get(url, headers = false) {
        if (!url) return false;

        return this.sendRequest(this.METHOD_GET, url, false, headers);
    }

    post(url, data = false, headers = false) {
        if (!url) return false;

        return this.sendRequest(this.METHOD_POST, url, data, headers);
    }

    put(url, data = false, headers = false) {
        if (!url) return false;

        return this.sendRequest(this.METHOD_PUT, url, data, headers);
    }

    delete(url, headers = false) {
        if (!url) return false;

        return this.sendRequest(this.METHOD_DELETE, url, false, headers);
    }
}